/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package guiPlaylisted.view;

import controlPlaylisted.PlaylistController;

import dataPlaylisted.Playlist;

import guiPlaylisted.PlaylistedApp;
import java.io.FileNotFoundException;
import java.io.IOException;

import javax.swing.JDialog;
import javax.swing.JFrame;

/**
 *
 * @author Administrador
 */
public class PlaylistView {

    private static PlaylistView instance;

    private PlaylistController m_playlistCtrl;

    private Playlist m_playlist;

    private JDialog m_playlistCreate;
    private JDialog m_playlistCreateView;
    private JDialog m_playlistView;

    private MusicView m_musicView;

    private PlaylistView() throws FileNotFoundException, IOException, ClassNotFoundException{
        m_playlistCtrl = PlaylistController.getInstance();
        m_musicView = MusicView.getInstance();
    }

    public static PlaylistView getInstance() throws FileNotFoundException, IOException, ClassNotFoundException{
        if(instance == null)
            instance = new PlaylistView();
        return instance;
    }

    public MusicView getMusicView(){
        return m_musicView;
    }

    public Playlist makePlaylistStyle(String _style){
        m_playlist = m_playlistCtrl.makePlaylistbyStyle(_style);
        return m_playlist;
    }

    public Playlist makePlaylistCammelot(String _cammelot){
        m_playlist = m_playlistCtrl.makePlaylistbyCammelot(_cammelot);
        return m_playlist;
    }

    public void savePlaylist() throws ClassNotFoundException{
        m_playlistCtrl.setPlaylistonList(m_playlist);
    }

    public void runPlaylistData() throws FileNotFoundException, IOException, ClassNotFoundException{
        JFrame mainFrame = PlaylistedApp.getApplication().getMainFrame();
        m_playlistCreate = new guiPlaylistCreate(mainFrame,true);
        m_playlistCreate.setLocationRelativeTo(mainFrame);
        PlaylistedApp.getApplication().show(m_playlistCreate);
    }

    public void runPlaylistCreateView(Playlist _playlist) throws FileNotFoundException, IOException, ClassNotFoundException{
        JFrame mainFrame = PlaylistedApp.getApplication().getMainFrame();
        m_playlistCreateView = new guiPlaylistCreateView(mainFrame,true,_playlist);
        m_playlistCreateView.setLocationRelativeTo(mainFrame);
        PlaylistedApp.getApplication().show(m_playlistCreateView);
    }

    public void runPlaylistView(Playlist _playlist) throws FileNotFoundException, IOException, ClassNotFoundException{
        JFrame mainFrame = PlaylistedApp.getApplication().getMainFrame();
        m_playlistView = new guiPlaylistView(mainFrame,true,_playlist);
        m_playlistView.setLocationRelativeTo(mainFrame);
        PlaylistedApp.getApplication().show(m_playlistView);
    }
    
}
